<!--全局结算政策列表-->
<template>
  <div>
    <f-search-form :more='false' @searchHandler='searchHandler'>
      <f-search-form-item label='商品名称' name='drugsName'  />
      <f-search-form-item label='商品类型' name='drugType' :showAll='false' type='select' :data='api.busCommon.drugType'></f-search-form-item>
    </f-search-form>
    <f-table ref='table' rowKey='policyDrugId' :tableColumns='columns' :scroll='{x:1800}' :multiple='false' :operator='operator' :params='queryParam' :api='api.bpd'>
       <span slot='drugsSpec' slot-scope='text, record, index'>
          <f-elipsis :text='text' :length='30'></f-elipsis>
        </span>
      <span slot='drugType' slot-scope='text, record, index'>
          <a-tag color='#FF0000' v-if='text=="ZS"'>
          招商
        </a-tag>
        <a-tag color='#00FF00' v-if='text=="ZY"'>
          自营
        </a-tag>
      </span>

      <span slot='deptPrice' slot-scope='text, record, index'>
         <span v-if='record.drugType=="ZY"'>{{ text }}</span>
         <sapn color='#00FF00' v-if='record.drugType=="ZS"'>
           -
         </sapn>
      </span>
      <span slot='settlePrice' slot-scope='text, record, index'>
         <span v-if='record.drugType=="ZY"'>{{ text }}</span>
         <sapn color='#00FF00' v-if='record.drugType=="ZS"'>
           -
         </sapn>
        </span>
      <span slot='action' slot-scope='text, record'>
          <template>
             <a @click='$refs.policyListDrawer.showDrawer(record)'>编辑</a>
            <a-divider type='vertical' />
          </template>
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
            <a-menu slot='overlay'>
               <a-menu-item>
                 <a href='javascript:;' @click='$refs.table.del(record)'>删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
      </span>
    </f-table>
    <policy-list-drawer ref='policyListDrawer'></policy-list-drawer>
    <drugs-form-drawer ref='drugsFormDrawer' @success='$refs.table.refresh()'></drugs-form-drawer>
  </div>
</template>
<script>
import api from "./../../js/api"
import PolicyListDrawer from "./components/policy_list_drawer"
import DrugsFormDrawer from "./components/drugs_form_drawer"
import { h } from "vue"

export default {
  name: "TableList",
  components: {
    DrugsFormDrawer,
    PolicyListDrawer
  },
  data() {
    let me = this
    //操作按钮
    let operator = []
    operator.push({
      name: "添加政策",
      icon: "plus",
      that: this,
      handler: (table, that) => {
        this.$refs.drugsFormDrawer.showDrawer()
      }
    })
    operator.push({
      name: "删除",
      icon: "delete",
      batch: true,
      handler: function(table) {
        table.remove()
      }
    })
    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      // 表头
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "center",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "商品名称",
          align: "left",
          width: "180px",
          ellipsis: true,
          length:30,
          sorter: true,
          dataIndex: "drugsName"
        },
        {
          title: "商品类型",
          align: "center",
          width: "80px",
          dataIndex: "drugType",
          scopedSlots: { customRender: "drugType" }
        },
        {
          title: "规格",
          align: "left",
          width: "180px",
          ellipsis: true,
          length:30,
          dataIndex: "drugsSpec"
        },
        {
          title: "生产企业",
          align: "left",
          width: "140px",
          length:20,
          ellipsis: true,
          dataIndex: "producersName"
        },
        {
          title: "使用数",
          align: "center",
          width: "60px",
          dataIndex: "policyPositionSize"
        },
        {
          title: "部门",
          align: "center",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "100px",
              dataIndex: "deptPrice",
              scopedSlots: { customRender: "deptPrice" }
            },
            {
              title: "结算标准",
              align: "center",
              width: "100px",
              dataIndex: "deptRate"
            }
          ]
        },
        {
          title: "电商",
          align: "center",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "100px",
              dataIndex: "settlePriceF3",
              scopedSlots: { customRender: "settlePrice" }
            },
            {
              title: "结算标准",
              align: "center",
              width: "100px",
              dataIndex: "settleRateF3"
            }
          ]
        },
        {
          title: "渠道商",
          align: "center",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "100px",
              dataIndex: "settlePrice",
              scopedSlots: { customRender: "settlePrice" }
            },
            {
              title: "结算标准",
              align: "center",
              width: "100px",
              dataIndex: "settleRate"
            }
          ]
        },
        {
          title: "大渠道商",
          align: "center",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "100px",
              dataIndex: "settlePriceF2",
              scopedSlots: { customRender: "settlePrice" }
            },
            {
              title: "结算标准",
              align: "center",
              width: "100px",
              dataIndex: "settleRateF2"
            }
          ]
        },
        {
          title: "商务经理",
          align: "center",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "100px",
              dataIndex: "settlePriceD",
              scopedSlots: { customRender: "settlePrice" }
            },
            {
              title: "结算标准",
              align: "center",
              width: "100px",
              dataIndex: "settleRateD"
            }
          ]
        },
        {
          title: "片区服务商",
          align: "center",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "100px",
              dataIndex: "settlePriceC",
              scopedSlots: { customRender: "settlePrice" }
            },
            {
              title: "结算标准",
              align: "center",
              width: "100px",
              dataIndex: "settleRateC"
            }
          ]
        },
        {
          title: "商务总负责人",
          align: "center",
          children: [
            {
              title: "结算价",
              align: "center",
              width: "100px",
              dataIndex: "settlePriceE",
              scopedSlots: { customRender: "settlePrice" }
            },
            {
              title: "结算标准",
              align: "center",
              width: "100px",
              dataIndex: "settleRateE"
            }
          ]
        },
        {
          title: "操作",
          align: "center",
          dataIndex: "action",
          width: "100px",
          fixed: "right",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {}
}
</script>

